package tgipl3.expert.theBananaCrop.minified;

import java.io.IOException;

public class UserMainCode
{
	static int output1 = 1;

	static void GetMaxDestroyed(String s)
	{
		String[] a = s.split(":"), o, p=a[3].substring(2, a[3].length() - 2).split("\\},\\{");
		int i = 0, j = 1, r = Integer.parseInt(a[0]), c = Integer.parseInt(a[1]), n = Integer.parseInt(a[2]), x[] = new int[n], y[] = new int[n];
		boolean b[][] = new boolean[r][c];
		for(; i < n; i++) {
			o = p[i].split(",");
			b[x[i] = Integer.parseInt(o[0]) - 1][y[i] = Integer.parseInt(o[1]) - 1] = true;
		}
		
		for(; j < n; j++) {
			for(i = 0; i < j; i++) {
				int e = x[i] - x[j], g = y[i] - y[j], f = x[j] - e, h = y[j] - g, m = 2;
				if(f >= 0 && f < r && h >= 0 && h < c)
					continue;
				b[f = x[i]][h = y[i]] = true;
				while(((f+=e) >= 0 && f < r && (h+=g) >= 0 && h < c || m > output1 && (output1 = m) < 0) && b[f][h])
					m++;
			}
		}
	}
	
	public static void main(String[] a) throws IOException {
		GetMaxDestroyed("6:7:14:{{2,1},{6,6},{4,2},{2,5},{2,6},{2,7},{3,4},{6,1},{6,2},{2,3},{6,3},{6,4},{6,5},{6,7}}");
		System.out.println(output1);
	}
}